package com.kcyu.sfhinvoice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kcyu.sfhinvoice.domain.CommonTemplate;
import com.kcyu.sfhinvoice.service.CommonTemplateService;
import com.kcyu.sfhinvoice.mapper.CommonTemplateMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
* @author kc-yu
* @description 针对表【common_template】的数据库操作Service实现
* @createDate 2024-01-03 23:36:41
*/
@Service
public class CommonTemplateServiceImpl extends ServiceImpl<CommonTemplateMapper, CommonTemplate>
    implements CommonTemplateService{

    @Override
    public List<CommonTemplate> queryTemplate(CommonTemplate commonTemplate) {
        QueryWrapper<CommonTemplate> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().like(StringUtils.hasText(commonTemplate.getBuyer()), CommonTemplate::getBuyer, commonTemplate.getBuyer())
                .eq(StringUtils.hasText(commonTemplate.getSeller()), CommonTemplate::getSeller, commonTemplate.getSeller())
                .like(StringUtils.hasText(commonTemplate.getTaxNumber()), CommonTemplate::getTaxNumber, commonTemplate.getTaxNumber())
                .like(StringUtils.hasText(commonTemplate.getBank()), CommonTemplate::getBank, commonTemplate.getBank())
                .like(StringUtils.hasText(commonTemplate.getBankAccount()), CommonTemplate::getBankAccount, commonTemplate.getBankAccount())
                .orderByDesc(CommonTemplate::getCreateTime);
        return this.list(queryWrapper);
    }
}




